
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="page/head.jsp" %>
<html>
<head>
    <title>Title</title>
    <style>
        #searchForm > div {
            margin-right: 5px;
        }

        /*#searchForm input{*/
        /*    width: 20px;*/
        /*}*/
    </style>
</head>
<body>

<div class="container">
    <div class="row">
        <div class="col-md-12 text-center">
            <form class="form-inline" id="searchForm" method="post" action="/emp?method=getEmpsByMaps">
                <div class="form-group">
                    <label for="exampleInputName2">员工名</label>
                    <input type="text" class="form-control" id="exampleInputName2" name="ename" placeholder="员工名">
                </div>
                <div class="form-group">
                    开始
                    <input type="date" class="form-control" name="start">
                    至
                    <input type="date" class="form-control" name="end">
                </div>
                <div class="form-group">
                    <label class="radio-inline">
                        <input type="radio" name="esex" id="inlineRadio1" value="男"> 男
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="esex" id="inlineRadio2" value="女"> 女
                    </label>
                </div>
                <button type="submit" class="btn btn-default">搜索</button>
            </form>
        </div>
    </div>
    <div class="row">
        <div class="col-md-1 col-md-offset-2">
            <a href="/addEmp.jsp" class="btn btn-info" role="button">新增</a>
        </div>
    </div>
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <table class="table table-bordered table-hover">
                <thead>
                <tr>
                    <th>员工编码</th>
                    <th>员工姓名</th>
                    <th>员工性别</th>
                    <th>员工工资</th>
                    <th>员工密码</th>
                    <th>员工部门</th>
                    <th>员工出生日期</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="e" items="${info.list}" varStatus="i">
                    <tr>
                        <td>${e.eno}</td>
                        <td>${e.ename}</td>
                        <td>${e.esex}</td>
                        <td>${e.salary}</td>
                        <td>${e.pwd}</td>
                        <td>${e.d.dname}</td>
                        <td><fm:formatDate value="${e.bornDate}" pattern="yyyy-MM-dd"/></td>
                        <td>
                            <button type="button" onclick="del(${e.eno})" class="btn btn-danger">删除</button>
                            <button type="button" onclick="getEmp(${e.eno})" class="btn btn-danger">修改</button>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
                <tfoot>
                <tr align="center">
                    <td colspan="8" >
                        <nav aria-label="Page navigation">
                            <ul class="pagination">
                                <li>
                                    <a href="/emp?method=getEmpsByMaps&pageNum=1" aria-label="Previous">
                                        <span aria-hidden="true">首页</span>
                                    </a>
                                </li>
                                <li>
                                    <a href="/emp?method=getEmpsByMaps&pageNum=${info.prePage}" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <c:forEach var="i" items="${info.navigatepageNums}">
                                    <li ${info.pageNum==i?"class='active'":""}><a href="/emp?method=getEmpsByMaps&pageNum=${i}">${i}</a></li>
                                </c:forEach>
                                <li>
                                    <a href="/emp?method=getEmpsByMaps&pageNum=${info.nextPage}" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                                <li>
                                    <a href="/emp?method=getEmpsByMaps&pageNum=${info.pages}" aria-label="Next">
                                        <span aria-hidden="true">尾页</span>
                                    </a>
                                </li>
                            </ul>
                        </nav>
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
    <script>
        function getEmp(eno) {
            location.href="/emp?method=getEmpByEno&eno="+eno;
        }
        function del(eno) {
            if (confirm("是否确认删除")) {
                $.ajax({
                    url:"/emp?method=del&eno="+eno,
                    type:"get",
                    success:function (result) {
                        if (result==1) {
                            alert("删除成功");
                            location.reload();
                        }else{
                            alert("删除失败");
                        }
                    }
                })
            }
        }
    </script>

</body>
</html>
